/***************************************************************
 * Name:      gameMain.h
 * Purpose:   Defines Application Frame
 * Author:    Bruno, Henrique, Hugo ()
 * Created:   2012-06-01
 * Copyright:
 * License:
 **************************************************************/

#ifndef GAMEMAIN_H
#define GAMEMAIN_H

//(*Headers(gameFrame)
#include <wx/menu.h>
#include <wx/statusbr.h>
#include <wx/frame.h>
//*)
#include <wx/wx.h>
#include "gameShapes.h"

class Screen : public wxPanel
{

public:
    Screen(wxFrame *parent);
    void Start();
    void Pause();

    void OnPaint(wxPaintEvent& event);
    void OnKeyDown(wxKeyEvent& event);
    void OnTimer(wxTimerEvent& event);

    enum { ScreenWidth = 10, ScreenHeight = 22 };

    Tetrominoes & ShapeAt(int x, int y) { return screen[(y * ScreenWidth) + x]; }

    int SquareWidth() { return GetClientSize().GetWidth() / ScreenWidth; }
    int SquareHeight() { return GetClientSize().GetHeight() / ScreenHeight; }
    void ClearScreen();
    void DropDown();
    void OneLineDown();
    void PieceDropped();
    void RemoveFullLines();
    void NewPiece();
    bool TryMove(const Shape& newPiece, int newX, int newY);
    void DrawSquare(wxPaintDC &dc, int x, int y, Tetrominoes shape);

    wxTimer *timer;
    bool m_started;
    bool m_paused;
    bool m_notFalling;
    Shape m_curPiece;
    int m_curX;
    int m_curY;
    int m_linesRemoved;
    int m_speed;
    bool m_accelerated;
    bool m_randomColour;
    Tetrominoes screen[ScreenWidth * ScreenHeight];
    wxStatusBar *m_stsbar;
};

class gameFrame: public wxFrame
{
    public:

        gameFrame(wxWindow* parent,wxWindowID id = -1);
        virtual ~gameFrame();

    private:

        //(*Handlers(gameFrame)
        void OnQuit(wxCommandEvent& event);
        void OnAbout(wxCommandEvent& event);
        //*)
        void OnNewGame(wxCommandEvent& event);
        void OnSlow(wxCommandEvent& event);
        void OnNormal(wxCommandEvent& event);
        void OnFast(wxCommandEvent& event);
        void OnLinear(wxCommandEvent& event);
        void OnAccelerated(wxCommandEvent& event);
        void OnFixed(wxCommandEvent& event);
        void OnRandom(wxCommandEvent& event);

        //(*Identifiers(gameFrame)
        static const long idMenuQuit;
        static const long idMenuAbout;
        static const long ID_STATUSBAR1;
        //*)
        static const long idMenuNewGame;
        static const long idMenuSlow;
        static const long idMenuNormal;
        static const long idMenuFast;
        static const long idMenuLinear;
        static const long idMenuAccelerated;
        static const long idMenuFixed;
        static const long idMenuRandom;

        //(*Declarations(gameFrame)
        wxStatusBar* StatusBar1;
        //*)
        wxMenuItem* MenuItem3;

        Screen *screen;

        DECLARE_EVENT_TABLE()
};


#endif // GAMEMAIN_H
